<!DOCTYPE html>

<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>网络云盘客户端-个人中心</title>
<!--    <base href="/layuiadmin/">-->
    <link rel="stylesheet" href="/layuiadmin/node_modules/layui-src/dist/css/layui.css">
    <script type="text/javascript" src="/webjars/jquery/3.5.1/jquery.js"></script>
    <script type="text/javascript" src="/layuiadmin/node_modules/layui-src/dist/layui.all.js"></script>
</head>
<body>
<fieldset class="layui-elem-field layui-field-title" style="margin-top: 50px;">
    <legend>完善个人信息</legend>
</fieldset>
<div class="layui-row">
    <div class="layui-col-md6">
        <form class="layui-form" action="" method="post" enctype="multipart/form-data">
            <div class="layui-form-item">
                <label class="layui-form-label">真实姓名</label>
                <div class="layui-input-block">
                    <input type="text" name="title" required  lay-verify="required" placeholder="请输入真实姓名" autocomplete="off" class="layui-input">
                </div>
            </div>

            <div class="layui-form-item layui-form-text">
                <label class="layui-form-label">个人简介</label>
                <div class="layui-input-block">
                    <textarea name="desc" placeholder="请输入个人信息内容" class="layui-textarea"></textarea>
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-input-block">
                    <button class="layui-btn" lay-submit lay-filter="formDemo">确认更改</button>
                    <button type="reset" class="layui-btn layui-btn-primary">重置</button>
                </div>
            </div>
            <div class="layui-col-md3">
                <div class="layui-upload layui-col-lg-offset2">
                    <div class="layui-upload-list">
                        <img class="layui-upload-img" id="demo1" src="../userPhoto/photo01.jpg" style="width: 50%">
                        <p id="demoText"></p>
                        <button type="button" class="layui-btn" id="test1">上传图片</button>
                    </div>
                </div>
            </div>
        </form>
    </div>

</div>
<script>
    layui.use('upload', function(){
        var $ = layui.jquery,upload = layui.upload;
        //普通图片上传
        var uploadInst = upload.render({
            elem: '#test1',
            url: '/uploadHead.do',
            before: function(obj){
                //预读本地文件示例，不支持ie8
                obj.preview(function(index, file, result){
                    $('#demo1').attr('src', result); //图片链接（base64）
                });
            },
            done: function(res){
                //如果上传失败
                if(res.code > 0){
                    return layer.msg('上传失败');
                }
                //上传成功
                layer.msg("上传成功");
            },
            error: function(){
                //演示失败状态，并实现重传
                var demoText = $('#demoText');
                demoText.html('<span style="color: #FF5722;">上传失败</span> <a class="layui-btn layui-btn-xs demo-reload">重试</a>');
                demoText.find('.demo-reload').on('click', function(){
                    uploadInst.upload();
                });
            }
        });
    });
</script>

</body>
</html>
